﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebAppHappyNewYear.Filter;

namespace WebAppHappyNewYear.Controllers
{

    //[ServiceFilter(typeof(CustomExceptionFilterAttribute))]

    //[TypeFilter(typeof(CustomExceptionFilterAttribute))]

    //IFacotry 注册
    [CustomFilterFactoryAttribute(typeof(CustomExceptionFilterAttribute))]
    [CustomControllerActionFilter]
    //controller 注册
    //[CustomExceptionFilterAttribute]
    public class FourthController : Controller
    {
        private readonly IA _ia;

        public FourthController(IA ia)
        {
            _ia = ia;
        }


        //action 注册
        //[CustomExceptionFilterAttribute]


        [CustomActionActionFilter]
        public IActionResult Index()
        {
            int a = 0;
            int b = 1;
            int c = 3;
            var r = c / a;

            return View();
        }


        public IActionResult Info()
        {
            int a = 0;
            int b = 1;
            int c = 3;
            var r = c / a;

            return View();
        }

        [CustomFilterFactoryAttribute(typeof(CustomActionFilterAttribute))]
        public IActionResult FilterTest()
        {
            Console.WriteLine("FilterTest Running!");

            return View();
        }

        [CustomActionFilter2Attribute]
        public IActionResult FilterTest2()
        {
            Console.WriteLine("FilterTest2 Running!");

            return View();
        }

        [CustomActionFilter3Attribute]
        public IActionResult FilterTest3()
        {
            Console.WriteLine("FilterTest3 Running!");

            return View();
        }


        public IActionResult Information()
        {
            Console.WriteLine("Information Running!");

            _ia.Show(1, "Information IA show");

            return View();
        }
    }
}